package com.shellinghome.vehicle ;

import com.shellinghome.tools.Car;

public class Vehicle  {
	

	private String execute ;
	private	 int x  ;
	private int y  ;
	
	public Vehicle( ){

	}

	



	
	public void move (String execute ){

	if (execute.length( )==0) {
		return;		
	}


	if (execute.length( )==1) {

		if ("W".equals(execute)) {
		System.out.println("前进");	
		y++;	
		
		}
		if("S".equals(execute)){
		System.out.println("后退");
		y--;	
		
		}
		if("A".equals(execute)){
		System.out.println("向左");
		x--;
		
		}
		if("D".equals(execute)){
		System.out.println("向右");
		x++;	
		
		}	
			
	}


	if(execute.length( ) >1){
		String  execute1[ ]= execute.split(","); 
		for (int i = 0; i < execute1.length; i++){
			move(execute1[i] );
		}

	}

}


	public void end( ){
		
		if (Math.abs(x)>9) {
		System.out.println("超出控制范围");
			return;
			
		}
		if (Math.abs(y)>9) {
		System.out.println("超出控制范围");
			return;
		}
		
		else{		
		System.out.println("结束位置为"+x+","+y);	
		}
	}	




//============================================	

	public void setExecute(String execute ){
		this.execute =execute ;
	}

	public String getExecute( ){
		return execute ;
	}


	public void setX( int x){
		this.x= x;
	}

	public int getX( ){
		return x;
	}

	public void setY( int y ){
		this.y= y;
	}

	public int getY( ){
		return y;
	}
}